#ifndef ConversationManager_h
#define ConversationManager_h

#include <string>
#include <list>
#include <vector>
#include <windows.h>

// Includes for using TinyXML
#include "tinystr.h"
#include "tinyxml.h"

using namespace std;

struct cCharacterSpeaker {
	int miCharacterId;
	string macCharacterName;
};

enum eConversationNodeType {
	eNormalTalk,
	eChooseTalk,
	eEndConversation
};

struct cConversationNode {
	eConversationNodeType meType;
	string macText;
	float mfDuration;
	int miCharacterId;
	typedef vector<cConversationNode> cConversationChildren;
	cConversationChildren mChildren;
};

struct cConversation {
	string macName;
	cConversationNode mRoot;
};

class cConversationManager {
private:
	list<cCharacterSpeaker> mCharacters;
	list<cConversation> mConversations;
	cConversationNode * mpCurrentConversationNode;
	float mfMessageTime;
	unsigned muiChooseOption;
	bool mbIsInConversation;
	void ReadCharacters(TiXmlNode* lpRoot);
	void ReadConversations( TiXmlNode *lpRoot );
	void ParseConversation( TiXmlElement* lpElem );
	void ParseNode( TiXmlElement *lpElem, cConversationNode *lpCurrentNode );
	void NextMessage( unsigned luiNextMessageIndex );
	string SearchNameCharacter(int luiId);
public:
	void Init(string lacConversationFile );
	void Deinit( void );
	void Update( float lfTimestep );
	void Render();
	void StartConversation( const string &lacConversationId );
	inline bool IsInConversation() {return mbIsInConversation;}
};
#endif